package com.test.template.publish.using.elecbook.content;

import com.elecbook.content.model.po.Contribute;
import com.test.template.publish.config.manager.VelocityConfigManager;
import com.test.template.publish.config.util.VGenerateUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

@Slf4j
public class ContributeETC_Manager {

    /**
     * 测试测试manager读取配置文件效果
     */
    @Test
    public void testManager() {
        VelocityConfigManager vcManager = vcManager();
        vcManager.readConfigFile();
        System.out.println(vcManager.getIoFileMap());
    }

    /**
     * 获取一个manager,暂时为不规范写法
     * // TODO 修复manager
     *
     * @return
     */
    VelocityConfigManager vcManager() {
        return VelocityConfigManager.builder()
                .tableName("contribute")
                .clazzPo(Contribute.class)
                .controllerPrefix("/content/contribute")
                .controllerPackage("com.elecbook.content.api")
                .servicePackageName("com.elecbook.content.service")
                .jsEntityPath("@/model/")
                .jsApiPath("@/api/content/contribute/contribute.js")
                .baseTemplateDirectory("publish-manager-v2")
                .build();
    }

    // 批量生成,执行核心函数
    @Test
    public void testAllGenerate() {
        VelocityConfigManager vcManager = vcManager();
        vcManager.readConfigFile();
        VGenerateUtil.generate(vcManager);
    }
}
